package com.jcl.tree.service;


import com.jcl.tree.dao.MenuMapper;
import com.jcl.tree.po.Menu;
import com.jcl.tree.utils.TreeBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * @作者 江南一点雨
 * @公众号 江南一点雨
 * @微信号 a_java_boy
 * @GitHub https://github.com/lenve
 * @博客 http://wangsong.blog.csdn.net
 * @网站 http://www.javaboy.org
 * @时间 2019-09-27 7:13
 */
@Service
public class MenuService
{
    @Autowired
    private MenuMapper menuMapper;

    public List<Menu> getMenusByHrId(Integer id)
    {
        List<Menu> menuList = menuMapper.getMenusByHrId(id);
        try
        {
            menuList = TreeBuilder.buildTree(menuList);
        } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e)
        {
            e.printStackTrace();
        }
        return menuList;
    }
}
